﻿<UserControl x:Class="SIEGate.UI.UserControls.SubscriberMeasurementUserControl"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             mc:Ignorable="d" d:DesignHeight="675" d:DesignWidth="850"
             xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:myuc="clr-namespace:SIEGate.UI.UserControls"
             xmlns:uc="clr-namespace:GSF.TimeSeries.UI.UserControls;assembly=GSF.TimeSeries.UI.WPF"
             xmlns:tsfBinding="clr-namespace:GSF.TimeSeries.UI.Binding;assembly=GSF.TimeSeries.UI"
             Background="Transparent">

    <UserControl.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="/GSF.TimeSeries.UI.WPF;Component/Resources/CommonResource.xaml" />
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </UserControl.Resources>

    <StackPanel x:Name="StackPanelManageSubscriberMeasurements" Orientation="Vertical">

        <StackPanel.Resources>

            <Style TargetType="ListBox">
                <Setter Property="Width" Value="225" />
                <Setter Property="SelectionMode" Value="Multiple"/>
                <Setter Property="Height" Value="160" />
                <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto"/>
                <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto"/>
            </Style>

            <Style TargetType="Grid">
                <Setter Property="Margin" Value="5,0,5,0"/>
            </Style>

        </StackPanel.Resources>
        
        <StackPanel Orientation="Horizontal">
        
            <TextBlock Text="Subscriber"/>
            <ComboBox ItemsSource="{tsfBinding:Column Path=ItemsSource}" SelectedItem="{tsfBinding:Column Path=CurrentItem}" SelectedIndex="{tsfBinding:Column Path=CurrentSelectedIndex}" Width="250">
                <ComboBox.ItemTemplate>
                    <DataTemplate>
                        <TextBlock Text="{tsfBinding:Column Path=Name}" TextAlignment="Left" Padding="1" />
                    </DataTemplate>
                </ComboBox.ItemTemplate>
            </ComboBox>
        
        </StackPanel>

        <Grid DataContext="{tsfBinding:Column Path=CurrentItem}">

            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="Auto"/>
            </Grid.ColumnDefinitions>

            <TabControl Grid.Column="0">
                <TabItem Name="AllowedTab" Header="Allowed">
                    <StackPanel>
                        <TextBlock Text="Allowed Measurements" HorizontalAlignment="Left" FontWeight="Bold"/>
                        <uc:MeasurementPagerUserControl Name="AllowedMeasurementsPager" ItemsPerPage="13" Selectable="True" Searchable="True" ShowPageSize="False" Width="395" Height="360" VerticalAlignment="Top" Margin="0" />
                    </StackPanel>
                </TabItem>
                <TabItem Name="DeniedTab" Header="Denied">
                    <StackPanel>
                        <TextBlock Text="Denied Measurements" HorizontalAlignment="Left" FontWeight="Bold"/>
                        <uc:MeasurementPagerUserControl Name="DeniedMeasurementsPager" ItemsPerPage="13" Selectable="True" Searchable="True" ShowPageSize="False" Width="395" Height="360" VerticalAlignment="Top" Margin="0" />
                    </StackPanel>
                </TabItem>
            </TabControl>

            <StackPanel Orientation="Vertical" Grid.Column="1" HorizontalAlignment="Center" VerticalAlignment="Center">
                <Button Content="&gt;&gt;" ToolTip="Remove Measurements" Width="Auto" Margin="2" IsEnabled="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=StackPanel, AncestorLevel=2}, Path=DataContext.CanSave}" Click="RemoveMeasurementsButton_Click"/>
                <Button Content="&lt;&lt;" ToolTip="Add Measurements" Width="Auto" Margin="2" IsEnabled="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=StackPanel, AncestorLevel=2}, Path=DataContext.CanSave}" Click="AddMeasurementsButton_Click"/>
            </StackPanel>

            <StackPanel Grid.Column="3" Margin="0,35,0,0">
                <TextBlock Text="Available Measurements" HorizontalAlignment="Left" FontWeight="Bold"/>
                <uc:MeasurementPagerUserControl Name="AvailableMeasurementsPager" ItemsPerPage="13" Selectable="True" Searchable="True" ShowPageSize="False" Width="395" Height="360" VerticalAlignment="Top" Margin="0" />
            </StackPanel>

        </Grid>

        <Grid DataContext="{tsfBinding:Column Path=CurrentItem}" HorizontalAlignment="Center">
            
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="Auto"/>
            </Grid.ColumnDefinitions>
            
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
            </Grid.RowDefinitions>

            <TextBlock Grid.Column="0" Grid.Row="0" Text="Allowed Measurement Groups" HorizontalAlignment="Left" FontWeight="Bold"/>
            <TextBlock Grid.Column="2" Grid.Row="0" Text="Available Measurement Groups" HorizontalAlignment="Left" FontWeight="Bold"/>
            <TextBlock Grid.Column="4" Grid.Row="0" Text="Denied Measurement Groups" HorizontalAlignment="Left" FontWeight="Bold"/>

            <ListBox x:Name="ListBoxAllowedGroups" ItemsSource="{tsfBinding:Column Path=AllowedMeasurementGroups}" Grid.Row="1" Grid.Column="0" DisplayMemberPath="Value" SelectionMode="Extended" />
            <StackPanel Orientation="Vertical" Grid.Row="1" Grid.Column="1" Grid.RowSpan="2" HorizontalAlignment="Center" VerticalAlignment="Center">
                <Button Content="&gt;&gt;" Command="{Binding Path=DataContext.RemoveAllowedMeasurementGroupCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=StackPanel, AncestorLevel=2}}" 
                       CommandParameter="{Binding ElementName=ListBoxAllowedGroups, Path=SelectedItems}" ToolTip="Remove Allowed Measurement Groups" Width="Auto" Margin="2"/>
                <Button Content="&lt;&lt;" Command="{Binding Path=DataContext.AddAllowedMeasurementGroupCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=StackPanel, AncestorLevel=2}}" 
                       CommandParameter="{Binding ElementName=ListBoxAvailableGroups, Path=SelectedItems}" ToolTip="Add Allowed Measurement Groups" Width="Auto" Margin="2"/>
            </StackPanel>

            <ListBox x:Name="ListBoxAvailableGroups" ItemsSource="{tsfBinding:Column Path=AvailableMeasurementGroups}" Grid.Row="1" Grid.Column="2" DisplayMemberPath="Value" SelectionMode="Extended" />
            <StackPanel Orientation="Vertical" Grid.Row="1" Grid.Column="3" Grid.RowSpan="2" HorizontalAlignment="Center" VerticalAlignment="Center">
                <Button Content="&gt;&gt;" Command="{Binding Path=DataContext.AddDeniedMeasurementGroupCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=StackPanel, AncestorLevel=2}}" 
                       CommandParameter="{Binding ElementName=ListBoxAvailableGroups, Path=SelectedItems}" ToolTip="Add Denied Measurement Groups" Width="Auto" Margin="2"/>
                <Button Content="&lt;&lt;" Command="{Binding Path=DataContext.RemoveDeniedMeasurementGroupCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=StackPanel, AncestorLevel=2}}" 
                       CommandParameter="{Binding ElementName=ListBoxDeniedGroups, Path=SelectedItems}" ToolTip="Remove Denied Measurement Groups" Width="Auto" Margin="2"/>
            </StackPanel>

            <ListBox x:Name="ListBoxDeniedGroups" ItemsSource="{tsfBinding:Column Path=DeniedMeasurementGroups}" Grid.Row="1" Grid.Column="4" DisplayMemberPath="Value" SelectionMode="Extended" />            
            
        </Grid>
        
    </StackPanel>
    
</UserControl>
